package com.example.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
@Controller
public class RequestSortController {
	
	@GetMapping("/j/api/lts")
	public String test(HttpServletResponse response, HttpServletRequest request) {
		System.out.println("/j/api/lts");
		return request.getRequestURI();
	}
	
	@GetMapping(value = "/j/{shortcode}")
	public String accessShort(@PathVariable("shortcode") String shortCode, HttpServletResponse response, HttpServletRequest request) {
		System.out.println("/j/{shortcode}=" + shortCode);
		return request.getRequestURI();
	}
	
	@GetMapping(value = "/j/{file}.txt")
	public String txt(@PathVariable("file") String file, HttpServletResponse response, HttpServletRequest request) {
		System.out.println("/j/{file}.txt=" + file);
		return request.getRequestURI();
	}
	
	
	@GetMapping(value = "/m/{cName}/{shortCode}")
	public String accessHuoMa(@PathVariable("cName") String cName, @PathVariable("shortCode") String shortCode, HttpServletRequest request) {
		System.out.println("/m/{cName}/{shortCode}=" + cName + "," + shortCode);
		return request.getRequestURI();
	}
	
	@GetMapping(value = "/m/*/{file}.txt")
	public String txtM(@PathVariable("file") String file, HttpServletRequest request) {
		System.out.println("/m/*/{file}.txt=" + file);
		return request.getRequestURI();
	}
	
	@GetMapping(value = "/")
	public String a(HttpServletRequest request) {
		System.out.println("/");
		return request.getRequestURI();
	}
	
	@GetMapping(value = "/{file}.html")
	public String b(@PathVariable("file") String file, HttpServletRequest request) {
		System.out.println("/{file}.html=" + file);
		return request.getRequestURI();
	}
	
	
	@GetMapping(value = "/oss/{file}.txt")
	public String c(@PathVariable("file") String file, HttpServletRequest request) {
		System.out.println("/oss/{file}.txt" + file);
		return "redirect:https://i5xforyou-joy.oss-cn-beijing.aliyuncs.com/checkfile/wechat/" + file + ".txt";
	}
	
}